home *** CD-ROM | disk | FTP | other *** search
/ Resource for Source: C/C++ / Resource for Source - C-C++.iso / codelib6 / v_08_07 / 8n07071a < prev    next >
Encoding:
Text File  |  1995-11-01  |  574 b   |  30 lines

  1.  
  2.  
  3. typedef int Boolean;
  4. const Boolean TRUTH = 1;
  5. const Boolean FALSE = 0;
  6.  
  7. const int dim = 10;
  8.  
  9. class Stack {
  10. public:
  11.     // initialize stack to sane state
  12.     Stack()           { index = 0; }
  13.  
  14.     // push a int value
  15.     void push(int x)  { data[index++] = x; }
  16.  
  17.     // remove top value and return it
  18.     int pop()         { return data[--index]; }
  19.  
  20.     // returns true if empty
  21.     Boolean isempty() { return index == 0;
  22.  
  23.     // returns true if full
  24.     Boolean isfull()  { return index >= dim; }
  25. private:
  26.     int index;
  27.     int data[dim];
  28. };
  29.  
  30.